import request from "@/request/request";
import requestMock from "@/request/requestMock";

//获取一级列表
export const reqCategory1List = ()=>{
    return request.get("/admin/product/getCategory1")
}

//获取二级列表
export const reqCategory2List = (category1Id)=>{
    return request.get(`/admin/product/getCategory2/${category1Id}`)
}


//获取三级列表
export const reqCategory3List = (category2Id)=>{
    return request.get(`/admin/product/getCategory3/${category2Id}`)
}

//4.请求mock的banner数据
export const reqBannerList = ()=>{
    return requestMock.get(`/mock-api/banner`)
}
//5. 请求mock的floor数据
export const reqFloorList = ()=>{
    return requestMock.get(`/mock-api/floor`)
}

//6. 请求Search的数据
export const reqSearchList = (searchParams)=>{
    return request.post(`/api/list`,searchParams)
}

//7. 请求详情页的数据
export const reqDetailList = (skuId)=>{
    return request.get(`/api/item/${skuId}`)
}

//8. 添加购物车发送请求 更新购物车商品数量
export const reqAddOrUpdateCart = (skuId,skuNum)=>{
    return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}

//9. 请求购物车列表
export const reqCartList = ()=>{
    return request.get(`/api/cart/cartList`)
}

//10. 切换单个商品的选中状态
export const reqCartSingleChange = (skuID, isChecked) => {
    return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
  };

//11. 切换全部商品的选中状态
export const reqCartAllChange = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//12. 删除单个商品
export const reqCartSingleDelete = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

//13. 删除所有选中的商品
export const reqCartAllDelete = (skuIdList) => {
  return request.post(`/api/cart/batchDeleteCart`, skuIdList);
};
//14. 获取验证码
export const reqCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`);
};
//15. 发送注册
export const reqRegister = (userInfo) => {
  return request.post(`/api/user/passport/register`,userInfo);
};
//16. 登录
export const reqLogin = (userInfo) => {

    return request.post(`/api/user/passport/login`, userInfo);
  };

//17.获取用户信息
export const reqUserMessage = () => { 
    return request.get(`/api/user/passport/auth/getUserInfo`);
};

//18. 退出登录
export const reqLogout = () => {
  return request.get(`/api/user/passport/logout`);
};

//19. 获取交易页信息
export const reqTradeInfo = () => {
  return request.get(`/api/order/auth/trade`);
};
//20. 获取模拟的收货地址
export const reqAddress = ()=>{
  return requestMock.get(`/mock-api/address`)
}

//21. 提交订单
export const reqAddOrder = (tradeNo, tradeDeatil) => {
  return request.post(
    `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    tradeDeatil
  );
};


//22. 根据订单号获取支付详情
export const reqPayDetail = (orderId)=>{
  return request.get(`/api/payment/weixin/createNative/${orderId}`)
}

//23. 查询当前的支付状态
export const reqPayStatus =(orderId)=>{
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}

//24. 查询我的订单的分页列表
export const reqMyOrder = (page, limit) => {
  return request.get(`/api/order/auth/${page}/${limit}`);
};
